package com.itheima.web.controller;

import cn.hutool.core.date.DateUtil;
import com.itheima.domain.db.AnalysisByYear;
import com.itheima.web.manager.AnalysisManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AnalysisController {

    @Autowired
    AnalysisManager analysisManager;

    //获取首页统计数据
    @GetMapping("/dashboard/summary")
    public ResponseEntity findSummary(){
        return analysisManager.findSummary();
    }

    //新增、活跃用户、次日留存率按日期查询
    @GetMapping("/dashboard/users")
    public AnalysisByYear findSummaryView(
            @RequestParam("sd")Long startDate,
            @RequestParam("ed")Long endDate,
            @RequestParam("type")String type){
        return analysisManager.findSummaryView(startDate,endDate,type);
    }


}